import request from "@sc/request";
import { stringify } from 'qs';

export async function getOrganizaInsider(params) {//获取组织所有部门
  return request(`/api/v1/ucenter/department/selectTreeByOrgId?${stringify(params)}`, {
    method: 'GET',
  });
}
export async function searchOrganizaInsider(params) {//根据ID查询部门
  return request(`/api/v1/ucenter/department/select`, {
    method: 'POST',
    data: params
  })
}
export async function addOrganizaInsider(params) {//新增部门
  return request(`/api/v1/ucenter/department/save`, {
    method: 'POST',
    data: params
  })
}
export async function editOrganizaInsider(params) {//编辑部门
  return request(`/api/v1/ucenter/department/update`, {
    method: 'POST',
    data: params
  })
}
export async function deleteOrganizaInsider(params) {//删除部门
  return request(`/api/v1/ucenter/department/delete?${stringify(params)}`, {
    method: 'POST',
    data: params
  })
}
export async function getInsiderUserList(params) {//获取人员
  return request(`/api/v1/ucenter/selectDeptUserList?${stringify(params)}`, {
    method: 'GET',
  })
}
export async function setUserRole(params) {//设置人员权限
  return request(`/api/v1/ucenter/role/setUserRole`, {
    method: 'POST',
    data: params
  })
}
export async function changeUserDeptRel(params) {//更换人员所在部门
  return request(`/api/v1/ucenter/updateUserDeptRel`, {
    method: 'POST',
    data: params
  })
}
export async function inviteUserJoinOrg(params) {//邀请用户加入到XX组织 or 组织下的部门
  return request(`/api/v1/ucenter/apply/save`, {
    method: 'POST',
    data: params
  })
}
export async function fuzzySearchUser(params) {//根据手机号或者姓名精确查询用户
  return request(`/api/v1/ucenter/findUser/param?${stringify({param: 1})}`, {
    method: 'GET',
  })
}
export async function deleteDeptUserRel(params) {//根据用户id和部门id删除用户和部门关系
  return request(`/api/v1/ucenter/deleteDeptUserRel`, {
    method: 'DELETE',
    data: params
  })
}
//----------------------------权限----
export async function getRolesByOrgId(params) {//根据ORG查询角色权限列表
  return request(`/api/v1/ucenter/role/getRolesByOrgId?${stringify(params)}`, {
    method: 'GET',
  })
}